# Maintainer: Daniel M. Capella <polyzen@archlinux.org>
# Contributor: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Maxim Baz <$pkgname at maximbaz dot com>
# Contributor: Skydrome <skydrome@i2pmail.org>
# Contributor: Allan McRae <allan@archlinux.org>

pkgname=urlwatch
pkgver=2.26
pkgrel=2
pkgdesc='Tool for monitoring webpages for updates'
arch=('any')
url=https://thp.io/2008/urlwatch/
license=('BSD')
depends=('python-appdirs' 'python-cssselect' 'python-keyring' 'python-lxml'
         'python-minidb' 'python-requests' 'python-yaml')
makedepends=('python-build' 'python-installer' 'python-setuptools'
             'python-wheel')
checkdepends=('python-docutils' 'python-pycodestyle' 'python-pytesseract'
              'python-pytest')
optdepends=('lynx: for one of the html2text filter methods'
            'python-beautifulsoup4: for the beautify filter and one of the html2text filter methods'
            'python-cssbeautifier: for the beautify filter'
            'python-html2text: for one of the html2text filter methods'
            'python-jq: for the jq filter'
            'python-jsbeautifier: for the beautify filter'
            'python-pdftotext: for the pdf2text filter'
            'python-pyppeteer: for the browser job'
            'python-pytesseract: for the ocr filter')
source=("https://files.pythonhosted.org/packages/source/${pkgname::1}/$pkgname/$pkgname-$pkgver.tar.gz")
sha256sums=('b14bbe23d87b7d4ac8b4e71a51fd2066908a947ccf7b557c3e4f87b09f455e8f')
b2sums=('c7990b0ecca8bb18632ba717dabfed3e3cdf147ff463e1221c4f7002fcb862d162421ac927bd6a570369a1833268cc08668e284e425e954a4eea8d41cb30eafd')

build() {
  cd $pkgname-$pkgver
  python -m build --wheel --skip-dependency-check --no-isolation
}

check() {
  cd $pkgname-$pkgver
  pytest
}

package() {
  cd $pkgname-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl

  # Symlink license file
  local site_packages=$(python -c "import site; print(site.getsitepackages()[0])")
  install -d "$pkgdir"/usr/share/licenses/$pkgname
  ln -s "$site_packages"/$pkgname-$pkgver.dist-info/COPYING \
    "$pkgdir"/usr/share/licenses/$pkgname/COPYING
}
